home *** CD-ROM | disk | FTP | other *** search
- Path: ix.netcom.com!netnews
- From: sstrader@ix.netcom.com (Scott Strader )
- Newsgroups: comp.lang.c++
- Subject: Getting Pointer to Dialog
- Date: 17 Feb 1996 20:56:22 GMT
- Organization: Netcom
- Message-ID: <4g5fdm$d5b@cloner4.netcom.com>
- NNTP-Posting-Host: atl-ga8-18.ix.netcom.com
- X-NETCOM-Date: Sat Feb 17 12:56:22 PM PST 1996
-
- I'm using MSVC++ 4.0 with MFC and am having a problem with referencing a
- control on a dialog. I've got a workaround for this problem, but am
- curious if anyone knows why it's happening.
-
- I'm in a function outside of the dialog class, so I need to get a pointer
- to that class. I had used the .m_pMainWnd member of my application
- class, then cast it as a pointer to my specific dialog class:
-
- CPatchwmDlg * theDlg = (CPatchwmDlg *)theApp.m_pMainWnd;
-
- Made sense to me. Unfortunately, I got unhandled exception errors
- whenever I tried to use theDlg as a pointer to my class. When I looked
- at the address of theDlg and the address of .m_pMainWnd, I found that
- they were different and that the hWnds were different. I eventually read
- that the proper way is to use the .GetDlgItem() member function to get
- the hWnd of the specific control on the dialog.
-
- I'm still curious as to why the original method did not work. If anybody
- has any info, thanks.
-
- Scott S.
-